package com.edu.exam.enums;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 会话事件级别枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum SessionEventLevel implements BaseEnum {
    /** 信息级别 */
    INFO("INFO", "信息级别"),
    /** 警告级别 */
    WARNING("WARNING", "警告级别"),
    /** 错误级别 */
    ERROR("ERROR", "错误级别"),
    /** 严重级别 */
    CRITICAL("CRITICAL", "严重级别"),
    /** 致命级别 */
    FATAL("FATAL", "致命级别");

    private final String code;
    private final String description;

    SessionEventLevel(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static SessionEventLevel fromCode(String code) {
        for (SessionEventLevel level : values()) {
            if (level.getCode().equals(code)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }

    public static SessionEventLevel fromDescription(String description) {
        for (SessionEventLevel level : values()) {
            if (level.getDescription().equals(description)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Invalid description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}